package com.linksfield.topup.controller.ordermanage;

import com.linksfield.topup.utils.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: songgt
 * @date: 2019-12-19 10:20
 */
@RestController
public class ExcelExportController {

    //@ApiOperation(value = "试用用户-导出excel")
    //@GetMapping(path = "/test")
    public void exportTrialUserList(HttpServletResponse response, @RequestHeader(name = "x-access-token", required = false) String token) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("a", 1);
        map.put("b", 2);
        map.put("c", 3);
        map.put("d", 4);
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        list.add(map);
        String[] names = {"字段1", "字段2", "字段3", "字段4"};
        String[] keys = map.keySet().toArray(new String[map.size()]);
        String fileName = "测试Excel";
        ExcelUtil.exportExcel2007(response, fileName, names, keys, list);
    }

    //    @GetMapping(path = "/test1")
//    public ResultDataDto test1(HttpServletResponse response){
//        RequestOrderExport request = new RequestOrderExport();
//        request.setStartDate("2019-03-29");
//        request.setEndDate("2019-03-30");
//        request.setOptions("");//payId,deviceCode
//        request.setPartnerCode("P000270");
//        String token = "eyJ0eXBlIjoiand0IiwiYWxnIjoiSFMyNTYifQ.eyJ1c2VyTmFtZSI6ImFkbWluIiwiaWQiOjMsInVzZXJQd2QiOiIyMTIzMmYyOTdhNTdhNWE3NDM4OTRhMGU0YTgwMWZjMyIsImV4cCI6MTU3NjgwMjEyNywibmJmIjoxNTc2NzU4OTI3fQ.ILUA0Fe_YlGZVb4lD16cYkY5XbsY1zAlSNU5ucGr4OM";
//        return orderService.orderExport(request, token, response);
//    }
}
